﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Fluent="clr-namespace:Fluent">
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary
Source="pack://application:,,,/Fluent;component\Themes\Office2010\Controls\ScrollBarWhite.xaml" />
    <ResourceDictionary
Source="pack://application:,,,/Fluent;component\Themes\Office2010\Controls\BackstageControls.xaml" />
  </ResourceDictionary.MergedDictionaries>
  <Fluent:ObjectToImageConverter x:Key="StringToImageConvert" />
  <ControlTemplate x:Key="BackstageButtonControlTemplate" TargetType="{x:Type Fluent:Button}">
    <Grid Background="#00000000">
      <Border x:Name="border" BorderBrush="{x:Null}" BorderThickness="0" CornerRadius="1" Visibility="Collapsed"
              Background="{TemplateBinding Background}">
        <Border Margin="0" CornerRadius="1" BorderThickness="1" BorderBrush="#19000000" Background="#BFFFFFFF">
          <Border BorderBrush="#7FFFFFFF" BorderThickness="1" CornerRadius="1" Background="#33FFFFFF" />
        </Border>
      </Border>
      <StackPanel Orientation="Horizontal" Margin="16,0,15,0" HorizontalAlignment="Left" VerticalAlignment="Center">
        <ContentPresenter x:Name="iconImage" HorizontalAlignment="Left" Height="16" VerticalAlignment="Center"
                          Content="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StringToImageConvert}}"
                          Width="16" SnapsToDevicePixels="True" />
        <TextBlock Text="{TemplateBinding Header}" TextWrapping="NoWrap" VerticalAlignment="Center"
                   HorizontalAlignment="Left" Margin="5,0,0,0" TextTrimming="CharacterEllipsis" x:Name="controlLabel" />
      </StackPanel>
    </Grid>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsEnabled" Value="True" />
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="border" Value="Visible" />
      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" TargetName="iconImage" Value="0.5" />
        <Setter Property="Opacity" TargetName="controlLabel" Value="0.5" />
        <Setter Property="Effect" TargetName="iconImage">
          <Setter.Value>
            <Fluent:GrayscaleEffect />
          </Setter.Value>
        </Setter>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="BackstageButtonStyle" TargetType="{x:Type Fluent:Button}">
    <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}" />
    <Setter Property="Height" Value="26" />
    <Setter Property="Margin" Value="5,1" />
    <Setter Property="Template" Value="{StaticResource BackstageButtonControlTemplate}" />
    <Setter Property="Background"
            Value="{Binding Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:BackstageTabControl}}, FallbackValue=Red}" />
    <Setter Property="Foreground" Value="{DynamicResource BackstageFontBrush}" />
  </Style>
  <ControlTemplate x:Key="BackstageControlTemplate" TargetType="{x:Type Fluent:BackstageTabControl}">
    <ControlTemplate.Resources>
      <ResourceDictionary>
        <Style x:Key="{x:Type Fluent:Button}" TargetType="{x:Type Fluent:Button}"
               BasedOn="{StaticResource BackstageButtonStyle}" />
        <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}" BasedOn="{StaticResource ScrollBarWhite}" />
        <Style x:Key="{x:Type Fluent:DropDownButton}" TargetType="{x:Type Fluent:DropDownButton}"
               BasedOn="{StaticResource DropDownButtonBackstageStyle}" />
        <Style x:Key="{x:Type Fluent:ComboBox}" TargetType="{x:Type Fluent:ComboBox}"
               BasedOn="{StaticResource ComboBoxBackstageStyle}" />
        <Style x:Key="{x:Type Fluent:Spinner}" TargetType="{x:Type Fluent:Spinner}"
               BasedOn="{StaticResource SpinnerBackstageStyle}" />
      </ResourceDictionary>
    </ControlTemplate.Resources>
    <Grid Margin="0" Background="{DynamicResource BackstageBackgroundBrush}">
      <Grid.ColumnDefinitions>
        <ColumnDefinition MinWidth="107" Width="Auto" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Grid Height="Auto" Grid.Column="1">
        <Grid.Resources>
          <ResourceDictionary>
            <Style x:Key="{x:Type Fluent:Button}" TargetType="{x:Type Fluent:Button}"
                   BasedOn="{StaticResource ButtonBackstageStyle}" />
          </ResourceDictionary>
        </Grid.Resources>
        <Border HorizontalAlignment="Right" Margin="-100,0,0,0" VerticalAlignment="Bottom" Width="343" Height="181"
                Background="{TemplateBinding Background}" BorderThickness="0" SnapsToDevicePixels="True">
          <Image x:Name="image" Source="/Fluent;Component/Themes/Office2010/Images/BackstageCorner.png" Stretch="None"
                 VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="343" Height="181" SnapsToDevicePixels="True"
                 RenderTransformOrigin="0.5,0.5">
            <Image.RenderTransform>
              <TransformGroup>
                <ScaleTransform />
                <SkewTransform />
                <RotateTransform />
                <TranslateTransform />
              </TransformGroup>
            </Image.RenderTransform>
          </Image>
        </Border>
        <ContentPresenter x:Name="PART_SelectedContentHost" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                          Height="Auto" Grid.Column="1" ContentSource="SelectedContent" />
      </Grid>
      <Grid Margin="0" VerticalAlignment="Stretch" Background="{DynamicResource BackstagePanelBackgroundBrush}">
        <Border HorizontalAlignment="Right" Margin="0" Width="6" Height="Auto"
                BorderBrush="{DynamicResource RibbonTopBorderBrush}" BorderThickness="0,0,1,0"
                Background="{DynamicResource BackstagePanelShadowBackgroundBrush}" />
        <StackPanel Margin="0,5,0,0" Height="Auto" IsItemsHost="True"></StackPanel>
      </Grid>
      <Border Margin="0" VerticalAlignment="Top" Height="2" Grid.ColumnSpan="2" Background="{TemplateBinding Background}"
              OpacityMask="{DynamicResource BackstageTopOpacityBrush}">
        <Rectangle Stroke="{x:Null}" StrokeThickness="0" Fill="{DynamicResource BackstageTopBackgroundBrush}" />
      </Border>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="FlowDirection" Value="RightToLeft">
        <Setter Property="RenderTransform" TargetName="image">
          <Setter.Value>
            <TransformGroup>
              <ScaleTransform ScaleX="-1" />
              <SkewTransform />
              <RotateTransform />
              <TranslateTransform />
            </TransformGroup>
          </Setter.Value>
        </Setter>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="BackstageStyle" TargetType="{x:Type Fluent:BackstageTabControl}">
    <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}" />
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
    <Setter Property="Template" Value="{StaticResource BackstageControlTemplate}" />
    <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}" />
    <Setter Property="Background"
            Value="{Binding Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Fluent:Backstage}}, FallbackValue=Red}" />
  </Style>
</ResourceDictionary>